package com.ljx.itbbs.server.oss.controller;

import com.ljx.itbbs.common.domain.vo.resp.ApiResult;
import com.ljx.itbbs.common.utils.ServletUtil;
import com.ljx.itbbs.server.oss.domain.vo.req.UploadUrlReq;
import com.ljx.itbbs.server.oss.service.OssService;
import com.ljx.itbbs.oss.domain.vo.resp.OssResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(tags = "OSS接口")
@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    @ApiOperation("获取临时上传链接")
    @GetMapping("/upload/url")
    public ApiResult<OssResp> uploadUrl(@Valid UploadUrlReq req) {

        return ApiResult.success(ossService.uploadUrl(ServletUtil.getUserId(), req));
    }
}
